﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace 卷书.Utils
{
    public class LibraryFile
    {

        public string filename { get; set; }
        public string filepath { get; set; }
        public DateTime importdate { get; set; }
        public string hash { get; set; }
        public List<string> tags { get; set; }
        public string descriptions { get; set; }
        private FileInfo fileinfo { get; set; }

        private Literature Literature;


        public LibraryFile():this("") { }


        public LibraryFile(string filepath)
        {
            
            if (File.Exists(filepath))
            {
                this.filepath = filepath;
                fileinfo = new FileInfo(filepath);
                filename = Path.GetFileNameWithoutExtension(filepath);
                descriptions = "";
                tags = new List<string>();
                hash = GetTextHash(filepath);
                Literature = new Literature();
                importdate = DateTime.Now;
            }
        }

        private string  GetTextHash(string filepath)
        {
            string text = PDFHelper.GetText(filepath,2);
            return Encrypt.GetStringMD5(text);
        }


    }
}
